const app = getApp();
Component({
  options: {
    styleIsolation: 'shared' 
  },
  properties: {
    drawShow: {
      type: Boolean,
      value: false
    },
    type: {
      type: null,
      value: 1
    },
    newBlindBoxData: {
      type: null,
      value: {}
    }
  },
  lifetimes: {
    attached() {
      // 在组件实例刚刚被创建时执行
      this.getData();
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    allDataList: []
  },

  /**
   * 组件的方法列表
   */
  methods: {
    // 获取数据
    getData(){
      app._postNetWork({
        url: app.getNetAddresss(this.data.newBlindBoxData.api),
        data: { order_id: this.data.newBlindBoxData.order_id },
        success: ({data}) => {
          if(data.result) {
            this.setData({
              allDataList: data.data.data ? data.data.data : data.data.list
            })
          }else {
            wx.showToast({
              icon: 'none',
              title: data.msg,
              duration: 1500
            });
          }
        },
        fail: function (res) {
          console.log(res);
        }
      })
    },
    close() {
      this.triggerEvent("drawGoodsClose", false )
    },
    // 跳转到订单详情
    goOrderdetail(item) {
      wx.navigateTo({
        url: "/packageA/member/orderdetail/orderdetail?order_id=" + item.currentTarget.dataset.info.id,
      });
    }
  }
})
